package com.cloud.portmana.entity.dao.impl;

import com.cloud.portmana.entity.Saletongji;
import com.cloud.portmana.entity.dao.IBgStatisticsManaHoldDao;
import com.cloud.sysmana.dto.SysStore;
import com.cloud.util.base.BaseHibernateDao;
import com.cloud.util.base.IUserInfo;
import com.cloud.util.other.StringUtil;
import com.cloud.util.page.PageInfo;

public class BgStatisticsManaHoldDao extends BaseHibernateDao<Saletongji, String> implements IBgStatisticsManaHoldDao {
	@Override
	public PageInfo getPageInfo(PageInfo pageInfo, IUserInfo userInfo) {
		String hsql = "FROM Saletongji ";
		String countSql = "select COUNT(*) from Saletongji ";
		String whereSql = " ";
		String orderSql = "";
		
		
		pageInfo.setEntityClass(Saletongji.class);
		pageInfo.setListHbSql(hsql);
		pageInfo.setTotalCountHbSQL(countSql);
		return pageInfo;
	}
	/**
	 * 获取系统用户分页数据SQL
	 * @param pageInfo
	 * @return
	 */
	@Override
	public PageInfo listUserPage(PageInfo pageInfo){
		
		String hsql = "FROM Saletongji";
		String countSql = "SELECT COUNT(*) FROM Saletongji";
		String whereSql = " where 1=1";
		
		pageInfo.setTotalCountHbSQL(countSql+whereSql);
		pageInfo.setListHbSql(hsql+whereSql);
		
		return pageInfo;
	}
	@Override
	public String getAllsumOfflineByChejiaMark(String chejiaMark) {
		// TODO Auto-generated method stub
		
		String Allsumsql="select count(*) from imei_info_new where imei in (select imie from user_vehicle where chejia_num like '"+chejiaMark+"%') ";
		
		String Offlinesql = Allsumsql+ " and statistic_behavior = 2";
		System.out.println(Offlinesql);
		System.out.println(Allsumsql);
		
		String Allsum =this.getSessionFactory().getCurrentSession().createSQLQuery(Allsumsql).list().get(0).toString();
		String Offline = this.getSessionFactory().getCurrentSession().createSQLQuery(Offlinesql).list().get(0).toString();
		
		
		return Allsum+","+Offline;
	}
}
